import requests
from requests import utils

# 发送post请求 - 表单
url_login = "http://127.0.0.1:8787/dar/user/login"
header_login = {"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"}
data_login = {
    "user_name": "test01",
    "passwd": "admin123"
}
response = requests.post(url_login, data=data_login, headers=header_login)
# 获取cookie信息,cookies是一个属性，不是方法不需要加（）
# print(response.cookies)
# cookie信息转换为键值对形式
cookie = requests.utils.dict_from_cookiejar(response.cookies)
# print(cookie)

# 后续使用待cookie的信息
# 请求地址
url = "http://127.0.0.1:8787/api/order/customer/orderPlan/getMaterial"
# 请求头
header = {"Content-Type":"application/json;charset=UTF-8"}
# 请求 传入cookie
res = requests.get(url=url,cookies=cookie)
print(res.text)
